//
//  DSTabBarViewController.m
//  demo-圈子
//
//  Created by Mac on 15/8/10.
//  Copyright (c) 2015年 Itcast. All rights reserved.
//

#import "DSTabBarViewController.h"
#import "DSTabBarView.h"
#import "DSPopView.h"
#import "DSClickItemProtocol.h"

@interface DSTabBarViewController ()<DSClickItemProtocol>
{


}
@property (nonatomic,strong)DSTabBarView * tabBarView;
@property (nonatomic,strong)DSPopView * popView;

@end

@implementation DSTabBarViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    //移除系统的TabBar
    [self.tabBar removeFromSuperview];
    
    _tabBarView =[[DSTabBarView alloc]initWithFrame:CGRectMake(0, kUIScreenHeight-kTabBarHeight, kUIScreenWidth, kTabBarHeight)];

    //! 设置代理
    _tabBarView.delegate =self;
    
    _tabBarView.backgroundColor =[UIColor redColor];
    [self.view addSubview:_tabBarView];
    
  //popView
    _popView =[[DSPopView alloc]initWithFrame:CGRectMake(0, kUIScreenHeight-kPopViewHeight -kTabBarHeight, kUIScreenWidth, kPopViewHeight)];

    //cp
    _popView.hidden =YES;
    
  [self.view addSubview:_popView];
   

}

#pragma mark - 按钮点击
/*
-(void)changVC:(UIButton *)bt{
    
    //怎么理解
//    _popView.hidden =YES;
//    
//    [_tabBarView.subviews enumerateObjectsUsingBlock:^(UIButton *item, NSUInteger idx, BOOL *stop) {
//        item.selected =NO;
//    
//    }];
//    bt.selected =YES;
//    
//    if (bt.tag ==4) {
//        _popView.hidden =NO;
//    }


}
*/
#pragma mark -按钮点击代理方法
-(void)didClickIndex:(NSInteger)index{
    //cp
    _popView.hidden = YES;
     
    //处理第五个按钮 处理popView
    if (index < 4) {
        self.selectedIndex = index;
    }else if (index == 4) {
        //改变显示值
        _popView.hidden = NO;
    }else if (index > 4){
        self.selectedIndex = index - 1;
    }

}


//差一方法 jia le
#pragma mark -- 隐藏我的tabar
- (void)pushHidden:(BOOL)flag{
    
    //yes是隐藏的时候
    if (flag) {
        _popView.hidden = YES;
        _tabBarView.hidden = YES;
        
        
    }else{
        _tabBarView.hidden = NO;
    }
    
}
@end
